Learn R Programming

prim (version 1.0.22)

prim S3 methods: S3 methods for PRIM for multivariate data

Description

S3 methods PRIM for multivariate data.

Usage

# S3 method for prim
predict(object, newdata, y.fun.flag=FALSE, ...)
# S3 method for prim
summary(object, ..., print.box=FALSE)

Arguments

object

object of class prim

newdata

data matrix

y.fun.flag

flag to return y value of PRIM box rather than box label. Default is FALSE.

print.box

flag to print out limits of all PRIM boxes. Default is FALSE.

...

other parameters

Details

--The predict method returns the value of PRIM box number in which newdata are located.

--The summary method displays a table with three columns: box-fun is the y value, box-mass is the mass of the box, threshold.type is the threshold direction indicator: 1 = ">= threshold", -1 = "<=threshold". Each box corresponds to a row. The second last row marked with an asterisk is the box which collates the remaining data points not belonging to a specific PRIM box. The final row is an overall summary, i.e. box-fun is the overall mean of y and box-mass is 1.

Examples

Run this code
data(quasiflow)
qf <- quasiflow[1:1000,1:2]
qf.label <- quasiflow[1:1000,3]*quasiflow[1:1000,4]

qf.prim <- prim.box(x=qf, y=qf.label, threshold=c(0.3, -0.1), threshold.type=0,
  verbose=TRUE)
## verbose=TRUE prints out extra informaton about peeling and pasting

summary(qf.prim)
predict(qf.prim, newdata=c(0.6,0.2))

## using median insted of mean for the response y

qf.prim2 <- prim.box(x=qf, y=qf.label, threshold=c(0.5, -0.2),
  threshold.type=0, y.fun=median)
summary(qf.prim2)
predict(qf.prim2, newdata=c(0.6,0.2))

Run the code above in your browser using DataLab